/**
 * 
 */
package com.precisosoft.mathematize.server.domain;

/**
 * @author jewettdx
 *
 */
public class RequestContext {

	private String userName;
	  
	  private static ThreadLocalton localton = new ThreadLocalton();

	  private static class ThreadLocalton extends ThreadLocal<Object> {
	    protected synchronized Object initialValue() {
	      RequestContext context = new RequestContext();
	      return context;
	    }
	  }

	  private RequestContext() { }

	  public static RequestContext getLocalInstance() {
	    RequestContext context = (RequestContext) localton.get();
	    return context;
	  }

	  public void initRequestContext(String userName) {
	    this.userName = userName;
	  }

	  public void clearRequestContext() {
	    this.userName = null;
	  }

	  public String getUserName() {
	    return userName;
	  }

}
